function [discount,beca,stipend] = u45_2012(math,lang,private,demrecode)
%% Universidad Alberto Hurtado
lm=(math+lang)/2;
beca=zeros(size(lm,1),1);
stipend=zeros(size(lm,1),1);

%Beca Excelencia 100% toda la carrera
discount=(lm>=700);

%Beca exelencia primer a;o
if (demrecode==45014 || demrecode==45030 || demrecode==45024 || demrecode==45033 || demrecode==45028 || demrecode==45026 || demrecode==45034 || demrecode==45010 || demrecode==45017 || demrecode==45011 || demrecode==45006 || demrecode==45004)
    auxdiscount=0.25*(lm>=620)+0.25*(lm>=630)+0.2*(lm>=650);
    discount=max(discount,auxdiscount);
elseif demrecode==45031
    auxdiscount=0.25*(lm>=640)+0.25*(lm>=670)+0.2*(lm>=680);
    discount=max(discount,auxdiscount);
elseif demrecode==45002
    auxdiscount=0.5*(lm>=670)+0.2*(lm>=680);
    discount=max(discount,auxdiscount);
end

%Beca exelencia toda la carrera
if demrecode==45009
    auxdiscount=0.1*(lm>=630)+0.15*(lm>=640)+0.25*(lm>=650)+0.2*(lm>=670)+0.3*(lm>=680);
    discount=max(discount,auxdiscount);
elseif demrecode==45001 || demrecode==45005
    auxdiscount=0.25*(lm>=640)+0.25*(lm>=650)+0.2*(lm>=670)+0.3*(lm>=680);
    discount=max(discount,auxdiscount);
end

%Beca pedagogia toda la carrera
if demrecode==45016
    auxdiscount=0.25*(lm>=540)+0.75*(lm>=600);
    discount=max(discount,auxdiscount);
elseif demrecode==45008 || demrecode==45018 || demrecode==45019 || demrecode==45020 || demrecode==45021 || demrecode==45025 || demrecode==45029 || demrecode==45035
    auxdiscount=0.25*(lm>=580)+0.75*(lm>=600);
    discount=max(discount,auxdiscount);
end

%Beca complementaria BVP
if (demrecode==45016 || demrecode==45008)
    stipend=900000*((private==0).*(lm>=620).*(lm<700));
elseif (demrecode==45018 || demrecode==45019 || demrecode==45020 || demrecode==45021 || demrecode==45025 || demrecode==45029 || demrecode==45035)
    stipend=900000*((private==0).*(lm>=650).*(lm<700));
end

%BVP
if (demrecode==45016 || demrecode==45008 || demrecode==45018 || demrecode==45019 || demrecode==45020 || demrecode==45021 || demrecode==45025 || demrecode==45029 || demrecode==45035)
    [auxdiscount,auxstipend]=bvp(lm);
    discount=max(discount,auxdiscount);
    stipend=max(stipend,auxstipend);
end
end
